package me.jessyan.armscomponent.app.mvp.presenter.mine;

import android.app.Application;

import com.jess.arms.di.scope.FragmentScope;
import com.jess.arms.http.imageloader.ImageLoader;
import com.jess.arms.integration.AppManager;
import com.jess.arms.mvp.BasePresenter;

import javax.inject.Inject;

import androidx.fragment.app.Fragment;
import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.OnLifecycleEvent;
import me.jessyan.armscomponent.app.mvp.contract.mine.MineHomeContract;
import me.jessyan.armscomponent.commonsdk.core.User;
import me.jessyan.rxerrorhandler.core.RxErrorHandler;


/**
 * <p>
 * Author: Taozebi
 * Date: 08/16/2021 21:35
 * Description: describe of this class
 */
@FragmentScope
public class MineHomePresenter extends BasePresenter<MineHomeContract.Model, MineHomeContract.View> {
    @Inject
    RxErrorHandler mErrorHandler;
    @Inject
    Application mApplication;
    @Inject
    ImageLoader mImageLoader;
    @Inject
    AppManager mAppManager;

    @Inject
    public MineHomePresenter(MineHomeContract.Model model, MineHomeContract.View rootView) {
        super(model, rootView);
    }

    /**
     * 使用 2017 Google IO 发布的 Architecture Components 中的 Lifecycles 的新特性 (此特性已被加入 Support library)
     * 使 {@code Presenter} 可以与 {@link SupportActivity} 和 {@link Fragment} 的部分生命周期绑定
     */
    @OnLifecycleEvent(Lifecycle.Event.ON_CREATE)
    void onCreate() {
        //打开 App 时自动加载列表
    }

    public void getUser(){
        User user =mModel.getUser();
        mRootView.setUserInfo(user);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        this.mErrorHandler = null;
        this.mAppManager = null;
        this.mImageLoader = null;
        this.mApplication = null;
    }
}
